#include "Our.h"

namespace Sea_Battle
{
	
	void Our:: Shoot(int x,int y )
	 {
		 if(npc_field[x][y] >=0)
		 { 
			 npc_field[x][y]-=1;
		 }
	 }
	void Our:: Set_ship_with_1_deck (int x,int y )
	 {

		 if(x<=X_coordinat&&y<=Y_coordinat)
		 {
			 if(our_field[x][y] !=1)
			 {
			 our_field[x][y]=1;
			 }
		 }
	 }
	 void Our:: Set_ship_with_2_decks(int x, int y)
	 {
		 if(x<=X_coordinat&&y<=Y_coordinat)
		 {
			 if(our_field[x][y] !=1)
			 {
			 if(vertical==true)
			 {
				 if(y+1<=Y_coordinat)
				 {
				 
					 our_field [x] [y]=1;
					 our_field [x] [y+1]=1;
				 }
				 else
				 {
					 if(y-1<=0)
					 {
					 our_field [x] [y]=1;
					 our_field [x] [y-1]=1;
					 }
				 }
			 }
			 
			 else
			 { 
				 if(x+1<=X_coordinat)
				 {
				 our_field [x] [y]=1;
				 our_field [x+1] [y]=1;
				 }
				 else
				 {
					 if(x-1>=0)
				     {
						 our_field [x] [y]=1;
						 our_field [x-1] [y]=1;
				 
				     }
				 }
			   }
			 }
		 }
		 
	 }
	 void Our:: Set_ship_with_3_decks ( int x, int y)
	 {
		 if(x<=X_coordinat&&y<=Y_coordinat)
		 {
			 if(our_field[x][y] !=1)
			 {
			 if(vertical==true)
			 {
				 if(y+1<=Y_coordinat)
				 {
					 if(y-1>=0)
					 {
					  our_field [x] [y]=1;
				      our_field [x] [y+1]=1;
				      our_field [x] [y-1]=1;
					 }
					 else
					 {
						 if(y+2<=Y_coordinat)
						 {
					      our_field [x] [y]=1;
				          our_field [x] [y+1]=1;
				          our_field [x] [y+2]=1;
						 }
					 }
				 }
			 
			 }
			 else
			 {
			 if(x-1>=0)
					 {
					  our_field [x] [y]=1;
				      our_field [x+1] [y]=1;
				      our_field [x-1] [y]=1;
					 }
					 else
					 {
						 if(x+2<=Y_coordinat)
						 {
					      our_field [x] [y]=1;
				          our_field [x+1] [y]=1;
				          our_field [x+2] [y]=1;
						 }
					 }
			 
			 }
			 
		  }
		 }
			 else
			 {
				 if(x+1<=X_coordinat)
				 {
					 if(x-1>=0)
					 {
				      our_field [x] [y]=1;
				      our_field [x+1] [y]=1;
				      our_field [x-1] [y]=1;
					 }
					 else
					 {
						 if(x+2<=X_coordinat)
						 {
							 our_field [x] [y]=1;
				             our_field [x+1] [y]=1;
				             our_field [x+2] [y]=1;

						 
						 }
					 }
				 }
		    }
	 }
	 void Our::Set_ship_with_4_decks  ( int x,int y)
	 {
		 if(x<=X_coordinat&&y<=Y_coordinat)
		  {
		   if(our_field[x][y] !=1)
			 {
				 if(vertical==true)
			     {
				   if(y+1<=Y_coordinat&&y-1>=0 )
				   {	 if(y+2<=Y_coordinat)
				         {
				           our_field [x] [y]=1;
				           our_field [x] [y+1]=1;
				           our_field [x] [y-1]=1;
				           our_field [x] [y+2]=1;
				         }
				   else
				   {
				   if(y-2>=0)
				   {
					       our_field [x] [y]=1;
				           our_field [x] [y+1]=1;
				           our_field [x] [y-1]=1;
				           our_field [x] [y-2]=1;
				   
				   }
				   }
				   
				   }
			     }
			 else
			 {
				 if(x+1<=X_coordinat &&x+2<=X_coordinat)
			    { 
					if(x+2<=X_coordinat)
					{
					our_field [x] [y]=1;
				    our_field [x+1] [y]=1;
				    our_field [x-1] [y]=1;
				    our_field [x+2][y]=1;
					}
					else
					{
					if(x-2>=0)
					{
					our_field [x] [y]=1;
				    our_field [x+1] [y]=1;
				    our_field [x-1] [y]=1;
				    our_field [x-2][y]=1;
					}
					}

				}
		     }
		   }
		  }
	 
	 }
  bool Set_Bool(bool A)
  {
return  vertical = A;
  }
	
	
}
